﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace DAO
{
    public class DataProvider
    {
        //static string strCon = "Data Source=WIN-ODR7L6UN6R9;Initial Catalog=QLVCB;Integrated Security=True";
        static string strCon = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\phuong\\Desktop\\Phuongdvit\\QLVeChuyenBay\\QLVCB.mdf;Integrated Security=True;User Instance=True";
       
        static public SqlConnection ConnectDB(string dbName)
        {
          
            SqlConnection conn = new SqlConnection(strCon);
            conn.Open();
            return conn;

        }

        public void DongKetNoi(SqlConnection conn)
        {
            if (conn != null && conn.State == ConnectionState.Open)
                conn.Close();
        }
        public static DataSet GetDataSet(string sql)
        {
            SqlConnection cn = new SqlConnection(strCon);
            SqlDataAdapter da = new SqlDataAdapter(sql, cn);
            DataSet ds = new DataSet();
            da.Fill(ds);
            return ds;
        }
    }
}
